import React, { Component } from 'react';
import { Swiper } from 'antd-mobile'
import { index_banner } from '../utils/api';

class MySwipe extends Component {
    constructor(props) {
        super(props)
        this.state = {
            list: [{}]
        }

        index_banner().then((res) => {

            this.setState({ list: res.data.list })
        })
    }
    render() {
        return (
            <div className='myswipe'>
                {/* Swiper组件 */}

                <Swiper className='swiper' autoplay loop autoplayInterval="2000">
                    {
                        this.state.list.map((item, index) => {
                            return (
                                <Swiper.Item key={index}>
                                    <img src={item.pic} alt="" />
                                </Swiper.Item>
                            )
                        })
                    }
                </Swiper>
            </div>
        );
    }
}

export default MySwipe;